#include "LPC11xx.h"
#include "led.h"

void led_init(void)
{
  //1. 启用IOCONFIG模块
  LPC_SYSCON->SYSAHBCLKCTRL |= 1 << 16;
  //2.1 将PIO3_0引脚配置为GPIO功能
  LPC_IOCON->PIO3_0 &= ~0x7;
  //2.2 将PIO3_1引脚配置为GPIO功能
  LPC_IOCON->PIO3_1 &= ~0x7;
  //3. 启用GPIO模块
  LPC_SYSCON->SYSAHBCLKCTRL |= 1 << 6;
  //4 将PIO3_0和PIO3_1配置为输出
  LPC_GPIO3->DIR |= 3;
}

void led1_on(void)
{
  LPC_GPIO3->DATA &= ~1;
}

void led2_on(void)
{
  LPC_GPIO3->DATA &= ~(1 << 1);
}

void led1_off(void)
{
  LPC_GPIO3->DATA |= 1;
}

void led2_off(void)
{
  LPC_GPIO3->DATA |= 1 << 1;
}
